import 'dart:io';

import 'package:device_info_plus/device_info_plus.dart';

class DeviceInfoUtil {
  static DeviceInfoPlugin _deviceInfo = DeviceInfoPlugin();

  static Future<AndroidDeviceInfo> get _androidInfo async => await _deviceInfo.androidInfo;

  static Future<IosDeviceInfo> get _iosInfo async => await _deviceInfo.iosInfo;

  static Future<String?> get _identifier async =>
      Platform.isAndroid ? (await _androidInfo).androidId : (await _iosInfo).identifierForVendor;

  static Future<String?> get identifier => _identifier;

  static Future<String> get _phoneBrands async {
    if (Platform.isAndroid) {
      return (await _androidInfo).brand ?? '' + ' ' + (await _androidInfo).model!;
    }

    return (await _iosInfo).name! +
        ' ' +
        (await _iosInfo).utsname.machine! +
        ' ' +
        (await _iosInfo).systemName! +
        (await _iosInfo).systemVersion!;
  }

  static Future<String> get phoneBrands => _phoneBrands;

  static String get _deviceType => Platform.isAndroid ? '0' : '1';

  static String get deviceType => _deviceType;
}
